/***************************************************************************
 *   Copyright (C) 2008 by Tomasz Dubik                                    *
 *   tdubik@gmail.com                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef __TASKCONTAINER_H__
#define __TASKCONTAINER_H__
#include <vector>
#include <time.h>
#include "task.h"

using namespace std;
namespace Tasks
{
    class TaskContainer
    {
        public:
            TaskContainer();
            ~TaskContainer();
            int count(){ return m_Tasks.size();}
            UID addTask(const string& text,
                                        int progress,
                                        UID parentID,
                                        time_t modifyTime,
                                        UID selfID = 0);

            UID addTask(const string& text,
                                        int progress,
                                        UID parentID);
            Task* findTask(UID ID);
            void editTask(const string& text, UID ID);
            void setTaskProgress(int value, UID ID);
            void deleteTask(UID ID);
            time_t lastModifyTime(UID ID);
            void save(const char* fileName);
            void load(const char* filename);
            const Task::Vector& TasksData();            
            void storeDeleted(bool value){ m_StoreDeleted; }
        private:            
            //static TaskContainer* instance();
            void calculateCurrentID();

        private:
            Task::Vector    m_Tasks;
            UID             m_CurrentID;
            bool            m_StoreDeleted;
    };
}
#endif
